#include "StdAfx.h"

#include "Gpu Thermal Settings.h"

using namespace StillDesign::NvApi;

GpuThermalSettings::GpuThermalSettings( NV_GPU_THERMAL_SETTINGS thermalSettings )
{
	_sensors = gcnew array<GpuThermalSensorDetails>( NVAPI_MAX_THERMAL_SENSORS_PER_GPU );
	
	for( int x = 0; x < NVAPI_MAX_THERMAL_SENSORS_PER_GPU; x++ )
	{
		_sensors[ x ] = GpuThermalSensorDetails::ToManaged( thermalSettings, x );
	}
}

array<GpuThermalSensorDetails>^ GpuThermalSettings::Sensors::get()
{
	return _sensors;
}

//

GpuThermalSensorDetails GpuThermalSensorDetails::ToManaged( NV_GPU_THERMAL_SETTINGS thermalSettings, int sensorIndex )
{
	GpuThermalSensorDetails settings;
		settings._controller = (ThermalController)thermalSettings.sensor[ sensorIndex ].controller;
		settings._defaultMinTemp = thermalSettings.sensor[ sensorIndex ].defaultMinTemp;
		settings._defaultMaxTemp = thermalSettings.sensor[ sensorIndex ].defaultMaxTemp;
		settings._currentTemp = thermalSettings.sensor[ sensorIndex ].currentTemp;
		settings._target = (ThermalTarget)thermalSettings.sensor[ sensorIndex ].target;
	
	return settings;
}

ThermalController GpuThermalSensorDetails::Controller::get()
{
	return _controller;
}
int GpuThermalSensorDetails::DefaultMinimumTemperature::get()
{
	return _defaultMinTemp;
}
int GpuThermalSensorDetails::DefaultMaximumTemperature::get()
{
	return _defaultMaxTemp;
}
int GpuThermalSensorDetails::CurrentTemperatre::get()
{
	return _currentTemp;
}
ThermalTarget GpuThermalSensorDetails::Target::get()
{
	return _target;
}